package com.bys.security;

import com.bys.response.Result;
import com.bys.response.ReultCode;
import com.bys.util.RespUtils;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 *  匿名登录错误处理
 */
public class AuthLoginHandler implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
        RespUtils.sendData(response, Result.fail(ReultCode.TOKEN_ERR));
    }
}
